﻿(function ($) {
    $.fn.emoji = function () {
        var keys = '\呲牙|调皮|流汗|偷笑|再见|敲打|擦汗|猪头|玫瑰|流泪|大哭|嘘|酷|抓狂|委屈|便便|炸弹|菜刀|可爱|色|害羞|得意|吐|微笑|发怒|尴尬|惊恐|冷汗|爱心|示爱|白眼|傲慢|难过|惊讶|疑问|睡|亲亲|憨笑|爱情|衰|撇嘴|阴险|奋斗|发呆|右哼哼|拥抱|坏笑|飞吻|鄙视|晕|大兵|可怜|强|弱|握手|胜利|抱拳|凋谢|饭|蛋糕|西瓜|啤酒|飘虫|勾引|OK|爱你|咖啡|钱|月亮|美女|刀|发抖|差劲|拳头|心碎|太阳|礼物|足球|骷髅|挥手|闪电|饥饿|困|咒骂|折磨|抠鼻|鼓掌|糗大了|左哼哼|哈欠|快哭了|吓|篮球|乒乓球|NO|跳跳|怄火|转圈|磕头|回头|跳绳|激动|街舞|献吻|左太极|右太极|闭嘴';

        return this.each(function () {
            var regex = new RegExp('\\[(' + keys + ')\\]', 'g');
            $(this).html($(this).html().replace(regex, $.fn.emoji.replace));
        });
    };

    $.fn.emoji.replace = function () {

        var dic = new Array();
        dic["呲牙"] = "000";
        dic["调皮"] = "001";
        dic["流汗"] = "002";
        dic["偷笑"] = "003";
        dic["再见"] = "004";
        dic["敲打"] = "005";
        dic["擦汗"] = "006";
        dic["猪头"] = "007";
        dic["玫瑰"] = "008";
        dic["流泪"] = "009";
        dic["大哭"] = "010";
        dic["嘘"] = "011";
        dic["酷"] = "012";
        dic["抓狂"] = "013";
        dic["委屈"] = "014";
        dic["便便"] = "015";
        dic["炸弹"] = "016";
        dic["菜刀"] = "017";
        dic["可爱"] = "018";
        dic["色"] = "019";
        dic["害羞"] = "020";

        dic["得意"] = "021";
        dic["吐"] = "022";
        dic["微笑"] = "023";
        dic["发怒"] = "024";
        dic["尴尬"] = "025";
        dic["惊恐"] = "026";
        dic["冷汗"] = "027";
        dic["爱心"] = "028";
        dic["示爱"] = "029";
        dic["白眼"] = "030";
        dic["傲慢"] = "031";
        dic["难过"] = "032";
        dic["惊讶"] = "033";
        dic["疑问"] = "034";
        dic["睡"] = "035";
        dic["亲亲"] = "036";
        dic["憨笑"] = "037";
        dic["爱情"] = "038";
        dic["衰"] = "039";
        dic["撇嘴"] = "040";
        dic["阴险"] = "041";

        dic["奋斗"] = "042";
        dic["发呆"] = "043";
        dic["右哼哼"] = "044";
        dic["拥抱"] = "045";
        dic["坏笑"] = "046";
        dic["飞吻"] = "047";
        dic["鄙视"] = "048";
        dic["晕"] = "049";
        dic["大兵"] = "050";
        dic["可怜"] = "051";
        dic["强"] = "052";
        dic["弱"] = "053";
        dic["握手"] = "054";
        dic["胜利"] = "055";
        dic["抱拳"] = "056";
        dic["凋谢"] = "057";
        dic["饭"] = "058";
        dic["蛋糕"] = "059";
        dic["西瓜"] = "060";
        dic["啤酒"] = "061";
        dic["飘虫"] = "062";

        dic["勾引"] = "063";
        dic["OK"] = "064";
        dic["爱你"] = "065";
        dic["咖啡"] = "066";
        dic["钱"] = "067";
        dic["月亮"] = "068";
        dic["美女"] = "069";
        dic["刀"] = "070";
        dic["发抖"] = "071";
        dic["差劲"] = "072";
        dic["拳头"] = "073";
        dic["心碎"] = "074";
        dic["太阳"] = "075";
        dic["礼物"] = "076";
        dic["足球"] = "077";
        dic["骷髅"] = "078";
        dic["挥手"] = "079";
        dic["闪电"] = "080";
        dic["饥饿"] = "081";
        dic["困"] = "082";
        dic["咒骂"] = "083";

        dic["折磨"] = "084";
        dic["抠鼻"] = "085";
        dic["鼓掌"] = "086";
        dic["糗大了"] = "087";
        dic["左哼哼"] = "088";
        dic["哈欠"] = "089";
        dic["快哭了"] = "090";
        dic["吓"] = "091";
        dic["篮球"] = "092";
        dic["乒乓球"] = "093";
        dic["NO"] = "094";
        dic["跳跳"] = "095";
        dic["怄火"] = "096";
        dic["转圈"] = "097";
        dic["磕头"] = "098";
        dic["回头"] = "099";
        dic["跳绳"] = "100";
        dic["激动"] = "101";
        dic["街舞"] = "102";
        dic["献吻"] = "103";
        dic["左太极"] = "104";

        dic["右太极"] = "105";
        dic["闭嘴"] = "106";

        var key = arguments[1];
        //        var url = 'https://github.com/SCRAPTURE/jquery-emoji/raw/master/images/emojis';
        //        var extension = '.png';
        var numstr = dic[key];
        var src = "http://app.babyfun.cc/scripts/emoji/emotions/f_static_" + numstr + ".png";
        //        var src = url + '/' + aa + extension;
        return '<img class="emoji" width="20" height="20" align="absmiddle" src="' + src + '" />';
    };
})(jQuery);